package cn.tedu.store.mapper;

import java.util.Date;
import java.util.List;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import cn.tedu.store.entity.Address;

@RunWith(SpringRunner.class)
@SpringBootTest
public class AddressMapperTestCase {
	
	 @Autowired
	 private AddressMapper addressMapper;
	 
	 /**
	  * 插入收货地址数据
	  */
	 @Test
	 public void address() {
		 Date now = new Date();
		 Address address = new Address();
		 address.setUid(1);
		 address.setName("root");
		 address.setProvince("广东省");
		 address.setCity("珠海市");
		 address.setArea("香洲区");
		 address.setDistrict("广东省珠海市香洲区");
		 address.setZip("10000");
		 address.setAddress("广东省珠海市香洲区金价创意谷5栋606室");
		 address.setPhone("1008611");
		 address.setTel("010-10000");
		 address.setTag("学校");
		 address.setIsDefault(1);
		 address.setCreatedUser("王俊");
		 address.setCreatedTime(now);
		 address.setModifiedUser("Admin");
		 address.setModifiedTime(now);
		 Integer rows = addressMapper.addnew(address);
		 System.err.println("rows="+rows);
	 }
	 /**
	  * 获取某用户的收货地址数据的数量
	  */
	 @Test
	 public void getCountByUid(){
		 Integer count = addressMapper.getCountByUid(1);
		 System.err.println("count="+count);
	 }

	@Test
	public void findById(){
		Integer id = 5;
		Address address = addressMapper.findById(id);
		System.err.println(address);
	}
	 
	 @Test
	 public void updateNonDefault(){
		 Integer uid = 4;
		 Integer rows = addressMapper.updateNonDefault(uid);
		 System.err.println("rows="+ rows);
	 }
		
	 @Test	
	 public void updateDefault(){
		 Integer id = 5;
		 Integer rows = addressMapper.updateDefault(id);
		 System.err.println("rows="+ rows);
	 }

	@Test
	public void findLastModified() {
		Integer uid = 4;
		Address address = addressMapper.findLastModified(uid);
		System.err.println("address=" + address);
	}

	@Test
	public void deleteById() {
		Integer id = 7;
		Integer rows = addressMapper.deleteById(id );
		System.err.println("rows=" + rows);
	}
	 
	 
	 
	 
	 
	 
	 
}
